package com;

import cn.hutool.core.bean.BeanUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

public class TestCopy {
	
	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	static class A {
		private String a1;
		private String a2;
	}
	
	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	static class B {
		private String b1;
		private String b2;
	}
	
	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	static class AB {
		private String a1;
		private String a2;
		private String b1;
		private String b2;
	}
	
	public static void main(String[] args) {
		TestCopy.A a = new TestCopy.A("A1", "A2");
		TestCopy.B b = new TestCopy.B("B1", "B2");
		TestCopy.AB ab = BeanUtil.copyProperties(a, TestCopy.AB.class);
		System.out.println(ab);
		BeanUtil.copyProperties(b, ab);
		System.out.println(ab);
	}

}
